package com.company.command.impl;

import com.company.command.ICommand;
import com.company.constant.SysConstant;

import java.io.File;
import java.util.Scanner;

/**
 * @author : cyw
 * @date : created in  下午5:31 2021/6/11
 * @description : 进入输入的路径
 * @modified by :
 * @Version : $
 */

public class EnterInputPathCommand implements ICommand {
    @Override
    public synchronized void command() {
        System.out.print("输入进入目录的绝对地址\n");
        Scanner scanner1 = new Scanner(System.in);
        String path = scanner1.nextLine();
        File newDir = new File(path);
        if (!newDir.exists()){
            System.out.println("地址");
        }else if (newDir.isFile()){
            System.out.println("这是一个文件");
        }else {
            SysConstant.DEFAULT_ROOT_PATH = newDir.getPath();
            SysConstant.FILE = new File(SysConstant.DEFAULT_ROOT_PATH);
            System.out.println("当前目录： "+SysConstant.DEFAULT_ROOT_PATH);
        }
    }
}
